package com.yum.ms.controller;


import com.alibaba.fastjson.JSON;
import com.yum.ms.entity.vo.GoodsVO;
import com.yum.ms.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yum
 * @since 2022-02-16
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private IGoodsService goodsService;

    /**
     * windows优化前QPS：142.6
     * 查询商品列表
     * @return
     */
    @GetMapping("/list")
    public String getGoodsList() {
        return JSON.toJSONString(goodsService.selectGoodsVOList());
    }

    @GetMapping("/{goodsId}")
    public String getGoodsVO(@PathVariable Long goodsId) {
        return JSON.toJSONString(goodsService.selectGoodsVOById(goodsId));
    }
}
